<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 王琛
  Date: 2021/7/23
  Time: 17:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
${error}

<table class="table">
    <tr><th>id</th><th>装备名</th><th>状态</th></tr>
    <c:forEach items="${u}" var="item">
        <tr>
            <td>${item.id}</td>
            <td>${item.equipName}</td>
            <td>${item.state}</td>
            <td><input id="price" name="price" type="text ">价格 </td>
            <td><button onclick="sell(${item.id},${item.state},this)">上架</button></td>
        </tr>
    </c:forEach>
</table>
<script src="https://www.jq22.com/jquery/jquery-1.7.1.js"></script>
<script>
  function  sell(id,state,aa) {
    var p =$(aa).parent().parent().find("td").eq(3).find("input").val();
    console.info("p:" + $(aa).parent().html());
    $.ajax({
      //这个地址
      "url":"<%=request.getContextPath()%>/userequip/goSell",
      //这种方式
      "type":"post",
      //传递这样的数据
      "data":{"id":id,"state":state,"price":p},
      "dataType":"json",
      "success":function (data){
        console.log(data);
      },
      "error":function (a,b,c) {
        console.log(a);
        console.log(b);
        console.log(c);
      }
    });
  }
</script>
</body>
</html>
